//
//  BLMeetDetailController.m
//  Byelone
//
//  Created by 乔小乔 on 2021/2/8.
//

#import "BLMeetDetailController.h"
#import "BLMeetStatusView.h"

@interface BLMeetDetailController ()
@property (unsafe_unretained, nonatomic) IBOutlet UIView *viewInfo;
@property (unsafe_unretained, nonatomic) IBOutlet UIView *viewArea;
@property (unsafe_unretained, nonatomic) IBOutlet UIView *viewOrderInfo;

@property (unsafe_unretained, nonatomic) IBOutlet UIView *viewStatus;
@property (weak, nonatomic) IBOutlet UILabel *labelOrder;
@property (weak, nonatomic) IBOutlet UILabel *labelOrderTime;
@property (weak, nonatomic) IBOutlet UILabel *labelStatus;
@property (weak, nonatomic) IBOutlet UILabel *labelStatusTime;
@property (weak, nonatomic) IBOutlet UILabel *labelBoardRoom;
@property (weak, nonatomic) IBOutlet UILabel *labelRoomTime;
@property (weak, nonatomic) IBOutlet UILabel *labelMeet;
@property (weak, nonatomic) IBOutlet UILabel *labelMeetTime;
@property (weak, nonatomic) IBOutlet UILabel *labelName;
@property (weak, nonatomic) IBOutlet UILabel *labelDesc;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *layoutAreaHeight;

@property (weak, nonatomic) IBOutlet NSLayoutConstraint *layoutOrderHeight;


@property (nonatomic, strong) UIView *viewLastPoint;
@end

@implementation BLMeetDetailController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"订单详情";
    [self createUI];
}

- (void)createUI{
    self.view.backgroundColor = [UIColor chColorWithHexString:@"#F7F7F7"];
    
    self.viewInfo.layer.shadowColor = [UIColor colorWithRed:8/255.0 green:6/255.0 blue:4/255.0 alpha:0.07].CGColor;
    self.viewInfo.layer.shadowOffset = CGSizeMake(0,0);
    self.viewInfo.layer.shadowOpacity = 1;
    self.viewInfo.layer.shadowRadius = 5;
    self.viewInfo.layer.cornerRadius = 5;
    
    self.viewStatus.layer.shadowColor = [UIColor colorWithRed:8/255.0 green:6/255.0 blue:4/255.0 alpha:0.07].CGColor;
    self.viewStatus.layer.shadowOffset = CGSizeMake(0,0);
    self.viewStatus.layer.shadowOpacity = 1;
    self.viewStatus.layer.shadowRadius = 5;
    self.viewStatus.layer.cornerRadius = 5;
    
    CGFloat y = 26;
    CGFloat x = 23;
    NSArray *arrayColor = @[@"#6C72F5",@"#6C72F5",@"#CBCBCB"];
    for (int i=0; i<arrayColor.count; i++) {
        BLMeetStatusView *viewLine = [[BLMeetStatusView alloc]initWithFrame:CGRectMake(x, y, 14, 54.5)];
        [self.viewStatus addSubview:viewLine];
        NSString *color = arrayColor[i];
        viewLine.colorStr = color;
        y = y+54.5;
    }
    
    [self.viewStatus addSubview:self.viewLastPoint];
    self.viewLastPoint.frame = CGRectMake(x, y, 14, 14);
    
    
    CGFloat areaY = 0;
    NSArray *arrAreaStr = @[@"地址：北京市朝阳区望京SOHO",@"会议室地址：北京市朝阳区望京SOHO"];
    for (int i=0; i<arrAreaStr.count; i++) {
        NSString *str = arrAreaStr[i];
        UILabel *label = [self getLabelWithFram:CGRectMake(2, areaY, BL_WINDOW_WIDTH-58, 0) withText:str];
        [self.viewArea addSubview:label];
        areaY=areaY+label.frame.size.height+2;
    }
    self.layoutAreaHeight.constant = areaY+11;
    
    CGFloat orderY = 13;
    NSArray *arrStr = @[@"订单编号:3456789098765456",@"订单产生时间:2020-11-23",@"支付时间:2020-11-24"];
    for (int i=0; i<arrStr.count; i++) {
        NSString *str = arrStr[i];
        UILabel *label = [self getLabelWithFram:CGRectMake(2, orderY, BL_WINDOW_WIDTH-58, 0) withText:str];
        [self.viewOrderInfo addSubview:label];
        orderY=orderY+label.frame.size.height+2;
    }
    self.layoutOrderHeight.constant = orderY;
}

- (UILabel *)getLabelWithFram:(CGRect)frame withText:(NSString *)str{
    UILabel *label = [[UILabel alloc]initWithFrame:frame];
    label.font = [UIFont systemFontOfSize:10 weight:UIFontWeightMedium];
    label.textColor = [UIColor chColorWithHexString:@"#888888"];
    label.text = str;
    [label sizeToFit];
    CGSize size = label.frame.size;
    label.frame = CGRectMake(frame.origin.x, frame.origin.y,size.width , size.height);
    return label;;
}

- (UIView *)viewLastPoint{
    if (!_viewLastPoint) {
        _viewLastPoint = [[UIView alloc]init];
        _viewLastPoint.layer.cornerRadius = 7;
        _viewLastPoint.layer.masksToBounds = YES;
        _viewLastPoint.layer.borderWidth = 3;
        _viewLastPoint.layer.borderColor = [UIColor chColorWithHexString:@"#CBCBCB"].CGColor;
    }
    return _viewLastPoint;
}
@end
